home *** CD-ROM | disk | FTP | other *** search
- From: abell@mindspring.com (Andrew Bell)
- Message-ID: <4jvcrn$ch2@mule1.mindspring.com>
- X-Original-Date: Thu, 04 Apr 1996 02:43:24 GMT
- Path: in2.uu.net!bounce-back
- Date: 05 Apr 96 02:53:49 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: constness of private members and methods
- Organization: MindSpring Enterprises
- References: <m0u3992-000GcEC@7.kurahaupo.gen.nz> <3161eaa4.8216104@nntp.ix.netcom.com>
- X-Newsreader: Forte Agent .99.82
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMWSLSeEDnX0m9pzZAQFk7AGAkXlAmMvjma54SnOAINpJPUwMFwttp5EJ
- 8CNH9t10WLmyxk/4MXvvIYx/1oMqwnx1
- =X2Ju
-
- jdmorris@ix.netcom.com (Jason D. Morris) wrote:
- >Assuming you allow 'pure' and 'clean', the compiler would then have
- >to check to make sure your functions were in fact 'pure' and 'clean'.
- >If the compiler could do such checking as part of its array of
- >optimizations, why not just do it for every function as
- >part of a general optimization step?
-
- The problem is the compiler needs to know the "purity" of the
- functions a given function calls during its compilation, or it can't
- optimize the code. You would thus have to compile all the called
- functions first, and have that information available while you
- compile that given function. For reasons I hope are reasonably
- obvious, this is impossible. Conceivably you could have a compilation
- system that does a first pass compilation over all of the code,
- looking for purity of functions, and then a second pass to do the
- actual compilation, but that's a bit beyond the capabilities of most
- modern compilers...
-
- With the proposed idea, a function that claims to pure and isn't would
- be tagged with a compiler error. This might be problematic with
- templates, as instantiation for a particular type may lead to non-pure
- functions being called. Also, changing a function so that it is no
- longer pure may lead to a cascade of changes to other functions, as
- they would lose their purity tag. There are probably some other
- problems I may not have noticed also (libraries that depend on other,
- canging, libraries?)
-
- Before making this part of the standard, it would be nice to have some
- sample evidence of how much of a performance difference it makes in
- meaningful programs. In general, you can simulate this by saving in a
- variable what you would use multiple calls to get (this is not as nice
- for normal programming as having tags, however, as it would require
- substantially more work to change if the called function is no longer
- pure, or (even worse) might not get changed when it needs to be.
-
- Andrew Bell
- abell@mindspring.com
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-